﻿using System;
using AudioBookWS.ServiceUtil;
using System.IO;
using AudioCore.Biz;
using AudioCore.Entity;
using AudioCore.DAO;
using AudioCore.Common;

namespace AudioBook.AudioManagement
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            string strConfigValue = string.Empty;

            // Load root folder of file manage
            AppConfigUtils.GetString(GUIConstants.ConfigKey.ROOT_FILE_FOLDER, ref strConfigValue);
            GlobalParam.RootFileFolder = strConfigValue;
            if (!Directory.Exists(strConfigValue))
            {
                Directory.CreateDirectory(strConfigValue);
            }

            // Load data folder
            AppConfigUtils.GetString(GUIConstants.ConfigKey.DATA_FOLDER, ref strConfigValue);
            GlobalParam.DataFolder= strConfigValue;
            if (!Directory.Exists(strConfigValue))
            {
                Directory.CreateDirectory(strConfigValue);
            }

            // Load item type
            using (ItemTypeBiz bizItemType = new ItemTypeBiz())
            {
                GlobalParam.ItemTypeList = bizItemType.GetAllItemType();
            }
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}